package club.ruanx.spider.common.message;

import club.ruanx.mq.common.entity.MessageData;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @author 阮胜
 * @date 2018/11/28 21:44
 */
@SuppressWarnings("UnusedReturnValue")
@Component
@EnableBinding(SpiderMessageClient.class)
public class SpiderMessageSender {

    private final SpiderMessageClient spiderMessageClient;

    public SpiderMessageSender(SpiderMessageClient spiderMessageClient) {
        this.spiderMessageClient = spiderMessageClient;
    }

    public boolean outputSend(MessageData messageData) {
        return spiderMessageClient.output().send(MessageBuilder.withPayload(messageData).build());
    }

    public boolean inputSend(MessageData messageData) {
        return spiderMessageClient.input().send(MessageBuilder.withPayload(messageData).build());
    }
}
